package com.ruoyi.base.service.impl;

import java.util.List;

import com.ruoyi.base.util.GenCodeUtils;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.base.mapper.ProcedureClassifyMapper;
import com.ruoyi.base.domain.ProcedureClassify;
import com.ruoyi.base.service.IProcedureClassifyService;

/**
 * 工序分类Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-08-17
 */
@Service
public class ProcedureClassifyServiceImpl implements IProcedureClassifyService 
{
    @Autowired
    private ProcedureClassifyMapper procedureClassifyMapper;

    /**
     * 查询工序分类
     * 
     * @param id 工序分类主键
     * @return 工序分类
     */
    @Override
    public ProcedureClassify selectProcedureClassifyById(Long id)
    {
        return procedureClassifyMapper.selectProcedureClassifyById(id);
    }

    /**
     * 查询工序分类列表
     * 
     * @param procedureClassify 工序分类
     * @return 工序分类
     */
    @Override
    public List<ProcedureClassify> selectProcedureClassifyList(ProcedureClassify procedureClassify)
    {
        return procedureClassifyMapper.selectProcedureClassifyList(procedureClassify);
    }

    /**
     * 新增工序分类
     * 
     * @param procedureClassify 工序分类
     * @return 结果
     */
    @Override
    public int insertProcedureClassify(ProcedureClassify procedureClassify)
    {
        procedureClassify.setCreateTime(DateUtils.getNowDate());
        //填充数据
        SysUser user = SecurityUtils.getLoginUser().getUser();
        procedureClassify.setCreateBy(user.getUserName());
        procedureClassify.setCreateUser(user.getUserName());
        procedureClassify.setCreateRole(user.getRoles().get(0).getRoleName());

        procedureClassify.setProcedureClassifyNo(GenCodeUtils.getProcedureClassifyNo());
        return procedureClassifyMapper.insertProcedureClassify(procedureClassify);
    }

    /**
     * 修改工序分类
     * 
     * @param procedureClassify 工序分类
     * @return 结果
     */
    @Override
    public int updateProcedureClassify(ProcedureClassify procedureClassify) {

        return procedureClassifyMapper.updateProcedureClassify(procedureClassify);
    }

    /**
     * 批量删除工序分类
     * 
     * @param ids 需要删除的工序分类主键
     * @return 结果
     */
    @Override
    public int deleteProcedureClassifyByIds(Long[] ids)
    {
        return procedureClassifyMapper.deleteProcedureClassifyByIds(ids);
    }

    /**
     * 删除工序分类信息
     * 
     * @param id 工序分类主键
     * @return 结果
     */
    @Override
    public int deleteProcedureClassifyById(Long id)
    {
        return procedureClassifyMapper.deleteProcedureClassifyById(id);
    }
}
